package com.fileupload.upload.log;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 批量插入配置类
 * 管理批量日志插入的策略配置，包括时间间隔和记录数阈值
 * @author 小乙
 */
@Component
@ConfigurationProperties(prefix = "fileupload.batch.insert")
public class BatchInsertConfig {
    
    /**
     * 定时任务执行的时间间隔（分钟）
     */
    private int intervalMinutes = 1;
    
    /**
     * 触发批量插入的记录数阈值
     */
    private int recordThreshold = 100;
    
    /**
     * 批量插入的最大记录数限制
     */
    private int maxBatchSize = 1000;
    
    /**
     * 是否启用批量插入功能
     */
    private boolean enabled = true;
    
    /**
     * 重试次数
     */
    private int maxRetryCount = 3;
    
    /**
     * 重试间隔（毫秒）
     */
    private long retryIntervalMs = 1000;

    public int getIntervalMinutes() {
        return intervalMinutes;
    }

    public void setIntervalMinutes(int intervalMinutes) {
        this.intervalMinutes = intervalMinutes;
    }
    
    /**
     * 获取批量插入时间间隔（分钟）
     * 兼容方法，用于保持向后兼容性
     */
    public int getBatchInsertInterval() {
        return intervalMinutes;
    }

    public int getRecordThreshold() {
        return recordThreshold;
    }

    public void setRecordThreshold(int recordThreshold) {
        this.recordThreshold = recordThreshold;
    }

    public int getMaxBatchSize() {
        return maxBatchSize;
    }

    public void setMaxBatchSize(int maxBatchSize) {
        this.maxBatchSize = maxBatchSize;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public int getMaxRetryCount() {
        return maxRetryCount;
    }

    public void setMaxRetryCount(int maxRetryCount) {
        this.maxRetryCount = maxRetryCount;
    }

    public long getRetryIntervalMs() {
        return retryIntervalMs;
    }

    public void setRetryIntervalMs(long retryIntervalMs) {
        this.retryIntervalMs = retryIntervalMs;
    }

    @Override
    public String toString() {
        return "BatchInsertConfig{" +
                "intervalMinutes=" + intervalMinutes +
                ", recordThreshold=" + recordThreshold +
                ", maxBatchSize=" + maxBatchSize +
                ", enabled=" + enabled +
                ", maxRetryCount=" + maxRetryCount +
                ", retryIntervalMs=" + retryIntervalMs +
                '}';
    }
}